import pymysql


class sql_ssvid():

    def __init__(self):
        self.conn = pymysql.connect(host="47.94.151.63", port=3306, user="contest", passwd="1327764786",
                                    db="contest_data",
                                    charset="utf8")  # 这里写上面设置的密码
        self.cursor = self.conn.cursor()

    def get_ssvid(self, cve_id):
        ssvid = []
        for i in cve_id:
            sql = "select ssv_id from cve_ssv where cve_id = '{0}'".format(i)
            self.cursor.execute(sql)
            id = self.cursor.fetchone()
            if id is not None:
                ssvid.append(id[0])
            else:
                ssvid.append(None)
        self.cursor.close()
        self.conn.close()
        print("=================")
        print(ssvid)
        print("=================")
        return ssvid


if __name__ == "__main__":
    cve = ["CVE-2020-9484"]
    ssvid = sql_ssvid().get_ssvid(cve)
